﻿using System.Data.Entity.ModelConfiguration;
using Nop.Core.Domain.Directory;

namespace Nop.Data.Mapping.Directory
{
    public partial class HolidayMap : EntityTypeConfiguration<Holiday>
    {
        public HolidayMap()
        {
            this.ToTable("Holiday");
            this.HasKey(h => h.Id);

            this.Property(h => h.Name).HasMaxLength(255);
            this.Property(h => h.CountryCode).HasMaxLength(5);
            this.Property(h => h.Description).HasMaxLength(400);

            this.HasMany(h => h.StateProvinces)
                .WithMany()
                .Map(m => m.ToTable("Holiday_StateProvince_Mapping"));
        }
    }

    public partial class HolidayDateMap : EntityTypeConfiguration<HolidayDate>
    {
        public HolidayDateMap()
        {
            this.ToTable("HolidayDate");
            this.HasKey(hd => hd.Id);

            this.HasRequired(hd => hd.Holiday)
                .WithMany(h => h.Dates)
                .HasForeignKey(hd => hd.HolidayId);
        }
    }
}
